// Constants
var myimfu_sss = Components.classes["@mozilla.org/content/style-sheet-service;1"]
      .getService(Components.interfaces.nsIStyleSheetService);
var myimfu_ios = Components.classes["@mozilla.org/network/io-service;1"]
      .getService(Components.interfaces.nsIIOService);
      
var myimfu_prefs = Components.classes["@mozilla.org/preferences-service;1"]
                    .getService(Components.interfaces.nsIPrefBranch);
var myimfu_prefs = Components.classes["@mozilla.org/preferences-service;1"]
                    .getService(Components.interfaces.nsIPrefService);
myimfu_prefs = myimfu_prefs.getBranch("extensions.myimfu.");
var myimfu_prefs2 = Components.classes["@mozilla.org/preferences-service;1"]
                    .getService(Components.interfaces.nsIPrefBranch);
var myimfu_prefs2 = Components.classes["@mozilla.org/preferences-service;1"]
                    .getService(Components.interfaces.nsIPrefService);
myimfu_prefs2 = myimfu_prefs2.getBranch("image.");

// Open Credits Balance Page
function myimfu_cbp(event){
	var	date = new Date(),dec = date.getMonth()+12,
		month = date.getMonth()+1,lastmonth = month-1,
		day = date.getDate(),year = date.getFullYear(),
		lastyear = date.getFullYear()-1;
		if(lastmonth === 00){
		openUILink('http://www.imvu.com/catalog/web_credits_balance_log.php?start_date='+lastyear+'-'+dec+'-'+day+'&end_date='+year+'-'+month+'-'+day+'&per_page_limit=100', event, false, true);
		} else {
		openUILink('http://www.imvu.com/catalog/web_credits_balance_log.php?start_date='+year+'-'+lastmonth+'-'+day+'&end_date='+year+'-'+month+'-'+day+'&per_page_limit=100', event, false, true);}}


// Open forums or education center pages
function myimfu_opspec(type, num, event){
switch(type){
	case 1:
	openUILink('http://www.imvu.com/creators/education_center.php?category_id='+num, event, false, true);break;
	case 2:
	openUILink('http://www.imvu.com/catalog/modules.php?op=modload&name=phpbb2&file=viewforum.php&f='+num, event, false, true);break;}}

// Open various product pages
function myimfu_prodpn(event, prdn){
	var addy = getBrowser().contentWindow.location.href,pn = addy.substr(addy.indexOf("?")+13);
switch(event, prdn){
	case 1:				
	var prev = window.open('imvu:PeerReview?mcg=1&pid='+prodnum);prev.close();break;
	case 2:					
	openUILink('http://www.imvu.com/shop/web_search.php?derived_from='+pn, event, false, true);break;
	case 3:
	var prev = window.open('imvupreviewer:derive?product_id='+pn);prev.close();break;
	case 4:
	var prev = window.open('imvupreviewer:edit?product_id='+pn);prev.close();break;
	case 5:					
	openUILink('http://www.imvu.com/catalog/web_submit_product.php?submit_type=edit_product&edit_pid='+pn, event, false, true);break;
	case 6:
	openUILink('http://www.imvu.com/catalog/developer_report.php?reporttype=productinfo&product_id='+pn, event, false, true);break;
	case 7:					
	openUILink('http://www.imvu.com/shop/derivation_tree.php?products_id='+pn, event, false, true);break;}}

// Open personal latest outfits
function myimfu_myout(event){
   	gBrowser.addEventListener("DOMContentLoaded", myimfu_cmyout, true);
	openUILink('http://www.imvu.com/outfits/index.php', event, false, true);}

function myimfu_cmyout(){
	gBrowser.removeEventListener("DOMContentLoaded", myimfu_cmyout, true);
	var	fuid = content.document.getElementById("globalHeader").childNodes[1].childNodes[5].childNodes[1].childNodes[1].getAttributeNode("href").value, 
	     	uid = fuid.substr(fuid.indexOf("?")+6);
	window._content.document.location = "http://www.imvu.com/outfits/index.php?just_this_user=" + uid;}

// Open personal catalog
function myimfu_mycat(event){
	gBrowser.addEventListener("DOMContentLoaded", myimfu_cmycat, true);
    	openUILink('http://www.imvu.com/catalog/web_index.php', event, false, true);}

function myimfu_cmycat(){
	gBrowser.removeEventListener("DOMContentLoaded", myimfu_cmycat, true);
	var	fuid = content.document.getElementById("globalHeader").childNodes[1].childNodes[5].childNodes[1].childNodes[1].getAttributeNode("href").value,
		uid = fuid.substr(fuid.indexOf("?")+6);
	window._content.document.location = "http://www.imvu.com/shop/web_search.php?manufacturers_id=" + uid;}

// Open Randon Home Page
function myimfu_randhp(){  
	var rno=Math.floor(Math.random() * (24999999 - 10000000 + 1) + 10000000);	
	window._content.document.location = ('http://www.imvu.com/catalog/web_mypage.php?user='+rno);}

// Clone product tools
window.addEventListener("load", function() { myimfu_pbar.init(); }, false);
var myimfu_pbar = {
  init: function(){
  var appcontent = document.getElementById("appcontent");
  if(appcontent)
          appcontent.addEventListener("DOMContentLoaded", myimfu_pbar.onPageLoad, true);},

  onPageLoad: function(aEvent){
  var	doc = aEvent.originalTarget,
  	doc2 = aEvent.originalTarget.location.href,
	attop = myimfu_prefs.getIntPref("shctattop");
   	if(doc2.search("product.php") > -1) {
		var	pbar = doc.createElement("span"),
			arg2 = doc.getElementById("product"),
			movet = doc.getElementById("product-developer");
		ctools = movet.cloneNode(true);
		if (attop == 1)
		arg2.parentNode.insertBefore( ctools, arg2 );}
}}
window.removeEventListener("load", function() { myimfu_pbar.init(); }, false);

// Load stylesheets
window.addEventListener("load", function() { myimfu_styles.init(); }, false);
var myimfu_styles = {
  init: function(){
  var appcontent = document.getElementById("appcontent");
  if(appcontent)
          appcontent.addEventListener("DOMContentLoaded", myimfu_styles.onPageLoad, true);},

  onPageLoad: function(aEvent){
  var	sticknpref = myimfu_prefs.getIntPref("hidestic"),
	cleanpref = myimfu_prefs.getIntPref("fstclean"),
	badgepref = myimfu_prefs.getIntPref("hidebadg"),
	skinpref = myimfu_prefs.getIntPref("skin"),
	xclenpref = myimfu_prefs.getIntPref("forextclean"),
	sitefixpref = myimfu_prefs.getIntPref("sitefixes"),
	sty1 = myimfu_ios.newURI("chrome://myimfu/skin/fclean.css", null, null),
	sty2 = myimfu_ios.newURI("chrome://myimfu/skin/fcleanaggb.css", null, null),
	sty3 = myimfu_ios.newURI("chrome://myimfu/skin/fcleanaggw.css", null, null),
  	sty4 = myimfu_ios.newURI("chrome://myimfu/skin/fcleanmid.css", null, null),
	sty5 = myimfu_ios.newURI("chrome://myimfu/skin/hidestick.css", null, null),
	sty6 = myimfu_ios.newURI("chrome://myimfu/skin/hidebadge.css", null, null),
	sty7 = myimfu_ios.newURI("chrome://myimfu/skin/fxclean.css", null, null),
	sty8 = myimfu_ios.newURI("chrome://myimfu/skin/fmodern.css", null, null),
	sty9 = myimfu_ios.newURI("chrome://myimfu/skin/fmidnight.css", null, null),
	sty10 = myimfu_ios.newURI("chrome://myimfu/skin/fixes.css", null, null);
  	if(sticknpref == 0){
		if(myimfu_sss.sheetRegistered(sty5, myimfu_sss.USER_SHEET))myimfu_sss.unregisterSheet(sty5, myimfu_sss.USER_SHEET);}
	else if(sticknpref == 1){
 		if(!myimfu_sss.sheetRegistered(sty5, myimfu_sss.USER_SHEET))myimfu_sss.loadAndRegisterSheet(sty5, myimfu_sss.USER_SHEET);}
  	if(badgepref == 0){
		if(myimfu_sss.sheetRegistered(sty6, myimfu_sss.USER_SHEET))myimfu_sss.unregisterSheet(sty6, myimfu_sss.USER_SHEET);}
 	else if(badgepref == 1){
 		if(!myimfu_sss.sheetRegistered(sty6, myimfu_sss.USER_SHEET))myimfu_sss.loadAndRegisterSheet(sty6, myimfu_sss.USER_SHEET);}
	if(cleanpref == 0){
		if(myimfu_sss.sheetRegistered(sty1, myimfu_sss.USER_SHEET))myimfu_sss.unregisterSheet(sty1, myimfu_sss.USER_SHEET);
		if(myimfu_sss.sheetRegistered(sty2, myimfu_sss.USER_SHEET))myimfu_sss.unregisterSheet(sty2, myimfu_sss.USER_SHEET);
		if(myimfu_sss.sheetRegistered(sty3, myimfu_sss.USER_SHEET))myimfu_sss.unregisterSheet(sty3, myimfu_sss.USER_SHEET);
		if(myimfu_sss.sheetRegistered(sty4, myimfu_sss.USER_SHEET))myimfu_sss.unregisterSheet(sty4, myimfu_sss.USER_SHEET);}
 	else if(cleanpref == 1){
		if(!myimfu_sss.sheetRegistered(sty1, myimfu_sss.USER_SHEET))myimfu_sss.loadAndRegisterSheet(sty1, myimfu_sss.USER_SHEET);
		if(myimfu_sss.sheetRegistered(sty2, myimfu_sss.USER_SHEET))myimfu_sss.unregisterSheet(sty2, myimfu_sss.USER_SHEET);
		if(myimfu_sss.sheetRegistered(sty3, myimfu_sss.USER_SHEET))myimfu_sss.unregisterSheet(sty3, myimfu_sss.USER_SHEET);}
  	else if(cleanpref == 2){
		if(skinpref == 3){if(!myimfu_sss.sheetRegistered(sty3, myimfu_sss.USER_SHEET))myimfu_sss.loadAndRegisterSheet(sty3, myimfu_sss.USER_SHEET);}
		else{if(!myimfu_sss.sheetRegistered(sty2, myimfu_sss.USER_SHEET))myimfu_sss.loadAndRegisterSheet(sty2, myimfu_sss.USER_SHEET);}
		if(myimfu_sss.sheetRegistered(sty1, myimfu_sss.USER_SHEET))myimfu_sss.unregisterSheet(sty1, myimfu_sss.USER_SHEET);}
	if(xclenpref  == 1){
		if(!myimfu_sss.sheetRegistered(sty7, myimfu_sss.USER_SHEET))myimfu_sss.loadAndRegisterSheet(sty7, myimfu_sss.USER_SHEET);}
	if(xclenpref  == 0){
		if(myimfu_sss.sheetRegistered(sty7, myimfu_sss.USER_SHEET))myimfu_sss.unregisterSheet(sty7, myimfu_sss.USER_SHEET);}
  	if(skinpref == 0){
		if(myimfu_sss.sheetRegistered(sty8, myimfu_sss.USER_SHEET))myimfu_sss.unregisterSheet(sty8, myimfu_sss.USER_SHEET);
		if(myimfu_sss.sheetRegistered(sty9, myimfu_sss.USER_SHEET))myimfu_sss.unregisterSheet(sty9, myimfu_sss.USER_SHEET);
  	 	if(myimfu_sss.sheetRegistered(sty4, myimfu_sss.USER_SHEET))myimfu_sss.unregisterSheet(sty4, myimfu_sss.USER_SHEET);}
 	else if(skinpref == 1){
 		if(!myimfu_sss.sheetRegistered(sty8, myimfu_sss.USER_SHEET))myimfu_sss.loadAndRegisterSheet(sty8, myimfu_sss.USER_SHEET);
		if(myimfu_sss.sheetRegistered(sty9, myimfu_sss.USER_SHEET))myimfu_sss.unregisterSheet(sty9, myimfu_sss.USER_SHEET);
  	 	if(myimfu_sss.sheetRegistered(sty4, myimfu_sss.USER_SHEET))myimfu_sss.unregisterSheet(sty4, myimfu_sss.USER_SHEET);}
	else if(skinpref == 3){
		if(cleanpref == 2){if(myimfu_sss.sheetRegistered(sty4, myimfu_sss.USER_SHEET))myimfu_sss.unregisterSheet(sty4, myimfu_sss.USER_SHEET);}
		else{if(!myimfu_sss.sheetRegistered(sty4, myimfu_sss.USER_SHEET))myimfu_sss.loadAndRegisterSheet(sty4, myimfu_sss.USER_SHEET);}
		if(myimfu_sss.sheetRegistered(sty8, myimfu_sss.USER_SHEET))myimfu_sss.unregisterSheet(sty8, myimfu_sss.USER_SHEET);
 		if(!myimfu_sss.sheetRegistered(sty9, myimfu_sss.USER_SHEET))myimfu_sss.loadAndRegisterSheet(sty9, myimfu_sss.USER_SHEET);}
	if(sitefixpref == 0){
		if(myimfu_sss.sheetRegistered(sty10, myimfu_sss.USER_SHEET))myimfu_sss.unregisterSheet(sty10, myimfu_sss.USER_SHEET);}
	else if(sitefixpref == 1){
		if(!myimfu_sss.sheetRegistered(sty10, myimfu_sss.USER_SHEET))myimfu_sss.loadAndRegisterSheet(sty10, myimfu_sss.USER_SHEET);}
	else {return;}
}}
window.removeEventListener("load", function() { myimfu_styles.init(); }, false);

// Tinyurl
function myimfu_turl(){
  var currentaddy = content.document.location;
  var address = "http://tinyurl.com/api-create.php?url="+currentaddy;
  gXMLHttpRequest = new XMLHttpRequest();
  gXMLHttpRequest.onload = myimfu_turlinline;
  gXMLHttpRequest.open("GET", address, true);
  gXMLHttpRequest.onreadystatechange = function (aEvt){
	  if (gXMLHttpRequest.readyState == 4){
	     if(gXMLHttpRequest.status == 200)
	      dump(gXMLHttpRequest.responseText);
	     else
	      dump("Error loading page\n");}};
  gXMLHttpRequest.send(null);
  addy = window.content.document;
  if(addy.getElementById('myimfutinyurl'))
    myimfu_turlclose();
  tindiv = addy.createElement("div");
  tindiv.id = "myimfutinyurl";
  tindiv.setAttribute('style', 'max-width:215px!important;z-index:999999!important;position:fixed!important;top:0px!important;right:1px!important;padding:4px!important;font-size:12px!important;border:1px black solid!important;background:grey!important');
  ctindiv = addy.createElement("div");
  ctindiv.setAttribute('style', 'color:#fff!important;font-size:15px!important;cursor:pointer!important;position:absolute!important;top:-5px!important;important;padding:3px!important;right:0!important');
  ctindiv.id = "myimfutinyclose";
  ctindiv.innerHTML = 'x'
  ctindiv.addEventListener('click', myimfu_turlclose, true);
  tindiv.appendChild(ctindiv);
  inDiv = addy.createElement("div");
  inDiv.setAttribute('style', 'color:#fff!important;margin-right:20px!important;font-size:14px!important');
  inDiv.id = "myimfutinyurlcont";
  inDiv.appendChild(addy.createTextNode('Loading'));
  tindiv.appendChild(inDiv);
  addy.body.appendChild(tindiv);}

function myimfu_turlinline(){
  theResponse = gXMLHttpRequest.responseText;
  addy = window.content.document;
  tindiv = addy.getElementById('myimfutinyurlcont');
  tindiv.replaceChild(addy.createTextNode((''+theResponse)), tindiv.firstChild);}

function myimfu_turlclose(){var old = window.content.document.body.removeChild(window._content.document.getElementById('myimfutinyurl'));}

// Fraudblock
document.addEventListener("load", function() { myimfu_fraudb.init(); }, true);

var myimfu_fraudb = {
  init: function(){
    var appcontent = document.getElementById("content");
    if(appcontent)
          appcontent.addEventListener("DOMContentLoaded", myimfu_fraudb.onPageLoad, false);},

  onPageLoad: function(aEvent){
  if(aEvent.originalTarget.domain == null){return;}else{
   var	skin = myimfu_ios.newURI("chrome://myimfu/skin/fraudprotect.css", null, null),
   	fraudpref = myimfu_prefs.getIntPref("fraudprot"),
	doc = aEvent.originalTarget,
	doc2 = aEvent.originalTarget.domain,
	doc3 = aEvent.originalTarget.location.href,
	strings = document.getElementById("myimfu-strings"),
	text1 = strings.getString('myimfuwarn1'),
	text2 = strings.getString('myimfuwarn2'),
	text3 = strings.getString('myimfuwarn3'),
	text4 = strings.getString('myimfuwarn4'),
	text5 = strings.getString('myimfuwarn5'),
	title = strings.getString('myimfuwarntitle');
   if(fraudpref == 1 ){
   	if(!myimfu_sss.sheetRegistered(skin, myimfu_sss.USER_SHEET))  
 	myimfu_sss.loadAndRegisterSheet(skin, myimfu_sss.USER_SHEET);
	if(doc2.indexOf("buyimvu.com") > -1 || doc2.indexOf("microsak.com") > -1 || doc2.indexOf("imved.com") > -1 || doc2.indexOf("eingee.com") > -1 || doc2.indexOf("mat2gip.be") > -1 || doc2.indexOf("hahaimvu.piczo.com") > -1 || doc3.search("geocities.com/xjaybrox") > -1 || doc2.indexOf("imvu-credit.com") > -1 || doc2.indexOf("igxe.com") > -1 || doc2.indexOf("imvucheatclub.com") > -1 || doc2.indexOf("thimvu.com") > -1 || doc2.indexOf("imvucredits.cn") > -1 || doc2.indexOf("igcoo.com") > -1 || doc2.indexOf("buyimvucredits.com") > -1 || doc2.indexOf("wow-gold-buy.com") > -1 || doc2.indexOf("ffxi-gil.net") > -1 || doc2.indexOf("imvub.com") > -1 || doc2.indexOf("gpkoo.com") > -1 || doc2.indexOf("imvu-cheat-vault.com") > -1 || doc2.indexOf("sellimvucr.com") > -1 || doc2.indexOf("imvucredits.cn") > -1 || doc2.indexOf("thimvu.com/") > -1 || doc2.indexOf("ig2t.com") > -1 || doc2.indexOf("ig4t.com") > -1 || doc2.indexOf("favorgame.net") > -1 ||	doc2.indexOf("online-game-store.com") > -1 || doc2.indexOf("imvu-cheatvault.net") > -1 || doc2.indexOf("imvucredits.com") > -1 || doc2.indexOf("metarl.com") > -1 || doc2.indexOf("samy-b.com") > -1 || doc2.indexOf("wowgoldbiz.com") > -1 || doc2.indexOf("vghp.com") > -1 || doc2.indexOf("crreseller.com") > -1 || doc2.indexOf("mmovo.com") > -1 || doc3.search("http://neasiescredits.synthasite.com") > -1 || doc2.indexOf("imvu-credits.net") > -1 || doc2.indexOf("llvgame.com") > -1 || doc2.indexOf("bygamer.com") > -1 || doc2.indexOf("imvucredits.us") > -1 || doc2.indexOf("imvuzone.com") > -1 || doc2.indexOf("gameim.com") > -1 || doc2.indexOf("freeimvucheaters.tk") > -1 || doc2.indexOf("gamesker.com") > -1 || doc2.indexOf("imvucheaters.com") > -1 || doc2.indexOf("imvucheaters.net") > -1 || doc2.indexOf("mmobread.com") > -1 || doc2.indexOf("imvuol.com") > -1 || doc2.indexOf("wowgoldcom.com") > -1 || doc2.indexOf("mari-boutique.net") > -1 || doc2.indexOf("eing.com") > -1 || doc2.indexOf("friskgame.com") > -1 || doc2.indexOf("theimvucredits.com") > -1 || doc2.indexOf("kongashop.com") > -1 || doc2.indexOf("dealomw.com") > -1 || doc2.indexOf("gamekoo.com") > -1 || doc2.indexOf("gameci.com") > -1 || doc2.indexOf("enrpg.com") > -1 || doc2.indexOf("gameseller.org") > -1 || doc2.indexOf("mmorpggold.us") > -1 || doc2.indexOf("mmobux.com") > -1 || doc2.indexOf("mmoitemshop.com") > -1 || doc2.indexOf("virgame.com") > -1 || doc2.indexOf("ugameshop.com") > -1){
		doc.title = title;
		var div = doc.createElement("span");
		div.setAttribute('id', 'imvufraudback');
		doc.getElementsByTagName("body")[0].appendChild(div);
		div.innerHTML = '<span id="imvufraudsymb"></span><p id="imvufraudinfo">'+text1+'<br>'+text2+' <a href="http://www.imvu.com/catalog/modules.php?op=modload&name=phpbb2&file=viewtopic.php&t=337100">'+text3+'</a> '+text4+'</p><p id="imvufrauddis">'+text5+'</p>';
		var link = doc.createElement("link");
		link.setAttribute('rel', 'shortcut icon');
		link.setAttribute('href', '%2FAAABAAcKBhETEBkaGCAiHycoJjM0Mj5APUVHRFFTUFZYVVlbWF9hXmhqZ21vbHZ4dXl7eH6AfcJ9AMt%2FAtN%2FAMSEAM%2BBAMGHAYmLiMyFAM%2BHAMuKAMONANuGBM6MAI%2BRjtmKBcuPANaNANyMAOKLAN6OAOCPANGUAJWXlNeTAOaPAuGRAN6TANmVAM%2BZAOCVAuGWBd2YAu2UAPSUAOqXAOSZC%2BaaAJ6gnfGYAOaaDuKcDfKZAeebEOCcIuCgAPOaBOWfAOKdHtyiAOSeEfCdBPKdAOWfE%2BagFfOfAO6gBfWgAOqjBOiiGKaopfGjAOOoBd2lNu2lC%2FOlAOKmL%2FCnAOaqAOmoDOupAPKpAOyqEKyuq%2BmpKvSqAOWvAPCtAPWsAu%2BsFd6sUe2wAPKvA%2FSwAPOwBvGvGd2vWfCzAPWxCu%2ByG%2FK0APG0C9%2BxYvO1ALS2s%2FS2APG0Htm0bPW3AOa0SuG0XvO2IPW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(skin, myimfu_sss.USER_SHEET);}
}}}
window.removeEventListener("load", function() { myimfu_fraudb.init(); }, false);

// Posting Tools
document.addEventListener("load", function() { myimfu_bbcode.init(); }, true);
var myimfu_bbcode = {
  init: function(){
    var appcontent = document.getElementById("content");
    if(appcontent)
          appcontent.addEventListener("DOMContentLoaded", myimfu_bbcode.onPageLoad, false);},

  onPageLoad: function(aEvent){
   var	posttool = myimfu_prefs.getIntPref("posttool"),
   	doc = aEvent.originalTarget,
	doc2 = aEvent.originalTarget.location.href;
   	if(doc2.search(".imvu.com") > -1 && posttool == 1){
	if(doc2.search("name=phpbb2&file=posting.php") > -1 || doc2.search("name=phpbb2&file=privmsg.php") > -1) {
	var fl = doc.createElement("input");
	fl.setAttribute('type', 'button');fl.setAttribute('style', 'width: 55px');fl.setAttribute('value', 'N URL');fl.setAttribute('name', 'cusbbnl');fl.setAttribute('class', 'button');
	var fl2 = doc.createElement("input");
	fl2.setAttribute('type', 'button');fl2.setAttribute('style', 'width: 64px');fl2.setAttribute('value', 'Img Link');fl2.setAttribute('name', 'cusbbn2');fl2.setAttribute('class', 'button');
	doc.getElementsByName("addbbcode14")[0].parentNode.appendChild(fl2);
	doc.getElementsByName("addbbcode16")[0].parentNode.appendChild(fl);
	fl2.addEventListener("click", myimfu_cusimglink2, false);
	fl.addEventListener("click", myimfu_cusnamelink2, false);}}
	if(doc2.search("imvu.com/groups/group") > -1 && posttool == 1){
	if(doc2.search("read.php?") > -1 || doc2.search("posting.php") > -1){
	var imfubuttons = doc.createElement("span");
	imfubuttons.setAttribute('id', 'custbuttons');
	var nl = doc.createElement("input");nl.setAttribute('type', 'button');nl.setAttribute('style', 'width: 50px');nl.setAttribute('value', 'N URL');nl.setAttribute('name', 'cusbbnl');nl.setAttribute('class', 'PhorumSubmit');
	var nl2 = doc.createElement("input");nl2.setAttribute('type', 'button');nl2.setAttribute('style', 'width: 60px');nl2.setAttribute('value', 'Img Link');nl2.setAttribute('name', 'cusbbn2');nl2.setAttribute('class', 'PhorumSubmit');nl2.setAttribute('id', 'cusbutspacer4');
	var nl3 = doc.createElement("input");nl3.setAttribute('type', 'button');nl3.setAttribute('style', 'width: 32px');nl3.setAttribute('value', 'Img');nl3.setAttribute('name', 'cusbbn3');nl3.setAttribute('class', 'PhorumSubmit');
	var nl4 = doc.createElement("input");nl4.setAttribute('type', 'button');nl4.setAttribute('style', 'width: 36px');nl4.setAttribute('value', 'URL');nl4.setAttribute('name', 'cusbbn4');nl4.setAttribute('class', 'PhorumSubmit');
	var nl5 = doc.createElement("input");nl5.setAttribute('type', 'button');nl5.setAttribute('style', 'width: 20px');nl5.setAttribute('value', 'b');nl5.setAttribute('name', 'cusbbn5');nl5.setAttribute('class', 'PhorumSubmit');
	var nl6 = doc.createElement("input");nl6.setAttribute('type', 'button');nl6.setAttribute('style', 'width: 20px');nl6.setAttribute('value', 'i');nl6.setAttribute('name', 'cusbbn6');nl6.setAttribute('class', 'PhorumSubmit');
	var nl7 = doc.createElement("input");nl7.setAttribute('type', 'button');nl7.setAttribute('style', 'width: 20px');nl7.setAttribute('value', 'u');nl7.setAttribute('name', 'cusbbn7');nl7.setAttribute('class', 'PhorumSubmit');nl7.setAttribute('id', 'cusbutspacer');
	var nl8 = doc.createElement("input");nl8.setAttribute('type', 'button');nl8.setAttribute('style', 'width: 50px');nl8.setAttribute('value', 'Strike');nl8.setAttribute('name', 'cusbbn8');nl8.setAttribute('class', 'PhorumSubmit');
	var nl9 = doc.createElement("input");nl9.setAttribute('type', 'button');nl9.setAttribute('style', 'width: 50px');nl9.setAttribute('value', 'Center');nl9.setAttribute('name', 'cusbbn9');nl9.setAttribute('class', 'PhorumSubmit');nl9.setAttribute('id', 'cusbutspacer2');
	var nl10 = doc.createElement("input");nl10.setAttribute('type', 'button');nl10.setAttribute('style', 'width: 35px');nl10.setAttribute('value', 'Sup');nl10.setAttribute('name', 'cusbbn10');nl10.setAttribute('class', 'PhorumSubmit');
	var nl11 = doc.createElement("input");nl11.setAttribute('type', 'button');nl11.setAttribute('style', 'width: 35px');nl11.setAttribute('value', 'Sub');nl11.setAttribute('name', 'cusbbn11');nl11.setAttribute('class', 'PhorumSubmit');nl11.setAttribute('id', 'cusbutspacer3');
	var nl12 = doc.createElement("input");nl12.setAttribute('type', 'button');nl12.setAttribute('style', 'width: 40px');nl12.setAttribute('value', 'Code');nl12.setAttribute('name', 'cusbbn12');nl12.setAttribute('class', 'PhorumSubmit');nl12.setAttribute('id', 'cusbutspacer5');
	var custbuttextarea = doc.getElementById("phorum_textarea");
	custbuttextarea.parentNode.insertBefore(imfubuttons, custbuttextarea);
	doc.getElementById("custbuttons").appendChild(nl5);
	doc.getElementById("custbuttons").appendChild(nl6);
	doc.getElementById("custbuttons").appendChild(nl7);
	doc.getElementById("custbuttons").appendChild(nl8);
	doc.getElementById("custbuttons").appendChild(nl9);
	doc.getElementById("custbuttons").appendChild(nl10);
	doc.getElementById("custbuttons").appendChild(nl11);
	doc.getElementById("custbuttons").appendChild(nl12);
	doc.getElementById("custbuttons").appendChild(nl3);
	doc.getElementById("custbuttons").appendChild(nl2);
	doc.getElementById("custbuttons").appendChild(nl4);
	doc.getElementById("custbuttons").appendChild(nl);
	nl.addEventListener("click", myimfu_cusnamelink, false);
	nl2.addEventListener("click", myimfu_cusimglink, false);
	nl3.addEventListener("click", myimfu_cusimg, false);
	nl4.addEventListener("click", myimfu_cusurl, false);
	nl5.addEventListener("click", function(){myimfu_cusfontsty("b")}, false);
	nl6.addEventListener("click", function(){myimfu_cusfontsty("i")}, false);
	nl7.addEventListener("click", function(){myimfu_cusfontsty("u")}, false);
	nl8.addEventListener("click", function(){myimfu_cusfontsty("s")}, false);
	nl9.addEventListener("click", function(){myimfu_cusfontsty("center")}, false);
	nl10.addEventListener("click", function(){myimfu_cusfontsty("sup")}, false);
	nl11.addEventListener("click", function(){myimfu_cusfontsty("sub")}, false);
	nl12.addEventListener("click", function(){myimfu_cusfontsty("code")}, false);
	}}}}
document.removeEventListener("load", function() { myimfu_bbcode.init(); }, true);

function myimfu_cusnamelink(){
var lvalue = content.document.getElementsByName("body")[0]
var lurl = prompt("Enter Link", "");
if(lurl==null) { return; }
var lname = prompt("Enter Name", ""); 
if(lname==null) { return; }
else { lvalue.value = lvalue.value += "[url="+lurl+"]"+lname+"[/url]" }}

function myimfu_cusnamelink2(){
var lvalue = content.document.getElementsByName("message")[0];
var lurl = prompt("Enter Link", "");
if(lurl==null) { return; }
var lname = prompt("Enter Name", "");
if(lname==null) { return; }
else { lvalue.value = lvalue.value += "[url="+lurl+"]"+lname+"[/url]" }}

function myimfu_cusimglink(){
var lvalue = content.document.getElementsByName("body")[0]
var liurl = prompt("Enter Link", "");
if(liurl==null) { return; } 
var liname = prompt("Enter Image Link", ""); 
if(liname==null) { return; } 
else { lvalue.value = lvalue.value += "[url="+liurl+"][img]"+liname+"[/img][/url]" }}

function myimfu_cusimglink2(){
var lvalue = content.document.getElementsByName("message")[0];
var liurl = prompt("Enter Link", "");
if(liurl==null) { return; } 
var liname = prompt("Enter Image Link", "");
if(liname==null) { return; } 
else { lvalue.value = lvalue.value += "[url="+liurl+"][img]"+liname+"[/img][/url]" }}

function myimfu_cusfontsty(type){
var imvutxtarea = content.document.getElementById("phorum_textarea");
var styletxt = imvutxtarea.value.substring(imvutxtarea.selectionStart, imvutxtarea.selectionEnd);
var selLength = imvutxtarea.textLength;
var selStart = imvutxtarea.selectionStart;
var selEnd = imvutxtarea.selectionEnd; 
if (selEnd == 1 || selEnd == 2) selEnd = selLength; 
var s1 = (imvutxtarea.value).substring(0,selStart); 
var s2 = (imvutxtarea.value).substring(selStart, selEnd) 
var s3 = (imvutxtarea.value).substring(selEnd, selLength); 
imvutxtarea.value = s1 + "["+type+"]" + s2 + "[/"+type+"]" + s3; return;} 

function myimfu_cusimg(){
var lvalue = content.document.getElementsByName("body")[0]
var liurl = prompt("Enter Image Link", "");
if(liurl==null) { return; } 
else { lvalue.value = lvalue.value += "[img]"+liurl+"[/img]" }}

function myimfu_cusurl(){
var lvalue = content.document.getElementsByName("body")[0]
var lurl = prompt("Enter Link", "");
if(lurl==null) { return; } 
else { lvalue.value = lvalue.value += "[url]"+lurl+"[/url]" }}

// Set Prefs
function myimfu_setpref(num){
  var	skindef = document.getElementById('myimfu_fskindef'),
  	skinmod = document.getElementById('myimfu_fskinmod'),
  	skinmid = document.getElementById('myimfu_fskinmid'),
	flceandis = document.getElementById('myimfu_fcdis'),
	fcleanen = document.getElementById('myimfu_fcen'),
	fcleanagg = document.getElementById('myimfu_fcagg'),
	titcleanen = document.getElementById('myimfu_titclen'),
	titcleandis = document.getElementById('myimfu_titcldis'),
	seccolen = document.getElementById('myimfu_seccole'),
	seccoldis = document.getElementById('myimfu_seccold'),
	hidesticen = document.getElementById('myimfu_hsticke'),
	hidesticdis = document.getElementById('myimfu_hstickd'),
	hidebadgen = document.getElementById('myimfu_hbadgen'),
	hidebadgdis = document.getElementById('myimfu_hbadgdis'),
	attopen = document.getElementById('myimfu_attopen'),
	attopdis = document.getElementById('myimfu_attopdis'),
	setanimon = document.getElementById('myimfu_setprefon'),
	setanimonce = document.getElementById('myimfu_setprefonce'),
	setanimoff = document.getElementById('myimfu_setprefoff'),
	fraudproen = document.getElementById('myimfu_fraudproe'),
	fraudprodis = document.getElementById('myimfu_fraudprod'),
	posttoolen = document.getElementById('myimfu_posttoole'),
	posttooldis = document.getElementById('myimfu_posttoold'),
	imfubar = document.getElementById('myimfu_tbar'),
	imfudevbar = document.getElementById('myimfu-devtbar'),
	setfull = document.getElementById('myimfu_modefull'),
	setficons = document.getElementById('myimfu_modeicon'),
	settext = document.getElementById('myimfu_modetext'),
	xcleanpref = myimfu_prefs.getIntPref("forextclean"),
	xclean = document.getElementById('myimfu_fxclean'),
	apch = document.getElementById('myimfu_apch'),
  	apitem1 = document.getElementById('myimfu_apitem1'),
  	apitem2 = document.getElementById('myimfu_apitem2'),
  	apitem3 = document.getElementById('myimfu_apitem3'),
  	apitem4 = document.getElementById('myimfu_apitem4'),
	vipch = document.getElementById('myimfu_vipch'),
  	vipitem1 = document.getElementById('myimfu_vipitem1'),
  	sitefixdis = document.getElementById('myimfu_fixd'),
  	sitefixen = document.getElementById('myimfu_fixe');
  switch(num){
  case 1:
	myimfu_prefs.setIntPref("skin", 0);skindef.setAttribute('checked', true);skinmod.setAttribute('checked', false);skinmid.setAttribute('checked', false);break;
  case 2:
    	myimfu_prefs.setIntPref("skin", 1);skindef.setAttribute('checked', false);skinmod.setAttribute('checked', true);skinmid.setAttribute('checked', false);break;
  case 3:
	myimfu_prefs.setIntPref("skin", 3);skindef.setAttribute('checked', false);skinmod.setAttribute('checked', false);skinmid.setAttribute('checked', true);break;
  case 4:
	myimfu_prefs.setIntPref("fstclean", 1);flceandis.setAttribute('checked', false);fcleanen.setAttribute('checked', true);fcleanagg.setAttribute('checked', false);break;
  case 5:
	myimfu_prefs.setIntPref("fstclean", 0);flceandis.setAttribute('checked', true);fcleanen.setAttribute('checked', false);fcleanagg.setAttribute('checked', false);break;
  case 6:
	myimfu_prefs.setIntPref("fstclean", 2);flceandis.setAttribute('checked', false);fcleanen.setAttribute('checked', false);fcleanagg.setAttribute('checked', true);break;
   case 7:
	myimfu_prefs.setIntPref("titleclean", 1);titcleanen.setAttribute('checked', true);titcleandis.setAttribute('checked', false);break;
   case 8:   
	myimfu_prefs.setIntPref("titleclean", 0);titcleanen.setAttribute('checked', false);titcleandis.setAttribute('checked', true);break;
   case 9:
	myimfu_prefs.setIntPref("seccol", 1);seccolen.setAttribute('checked', true);seccoldis.setAttribute('checked', false);break;
   case 10:
   	myimfu_prefs.setIntPref("seccol", 0);seccolen.setAttribute('checked', false);seccoldis.setAttribute('checked', true);break;
   case 11:
	myimfu_prefs.setIntPref("hidestic", 1);hidesticen.setAttribute('checked', true);hidesticdis.setAttribute('checked', false);break;
   case 12:
   	myimfu_prefs.setIntPref("hidestic", 0);hidesticen.setAttribute('checked', false);hidesticdis.setAttribute('checked', true);break;
   case 13:
	myimfu_prefs.setIntPref("hidebadg", 1);hidebadgen.setAttribute('checked', true);hidebadgdis.setAttribute('checked', false);break;
   case 14:
	myimfu_prefs.setIntPref("hidebadg", 0);hidebadgen.setAttribute('checked', false);hidebadgdis.setAttribute('checked', true);break;
   case 15:
	myimfu_prefs.setIntPref("shctattop", 1);attopen.setAttribute('checked', true);attopdis.setAttribute('checked', false);break;
   case 16:
	myimfu_prefs.setIntPref("shctattop", 0);attopen.setAttribute('checked', false);attopdis.setAttribute('checked', true);break;
  case 17:
	myimfu_prefs2.setCharPref("animation_mode", 'normal');setanimon.setAttribute('checked', true);setanimonce.setAttribute('checked', false);setanimoff.setAttribute('checked', false);break;
  case 18:
	myimfu_prefs2.setCharPref("animation_mode", 'once');setanimon.setAttribute('checked', false);setanimonce.setAttribute('checked', true);setanimoff.setAttribute('checked', false);break;
  case 19:	
	myimfu_prefs2.setCharPref("animation_mode", 'none');setanimon.setAttribute('checked', false);setanimonce.setAttribute('checked', false);setanimoff.setAttribute('checked', true);break;
  case 20:
	myimfu_prefs.setIntPref("fraudprot", 1);fraudproen.setAttribute('checked', true);fraudprodis.setAttribute('checked', false);break;
  case 21:
	myimfu_prefs.setIntPref("fraudprot", 0);fraudproen.setAttribute('checked', false);fraudprodis.setAttribute('checked', true);break;
  case 22:
	myimfu_prefs.setIntPref("posttool", 1);posttoolen.setAttribute('checked', true);posttooldis.setAttribute('checked', false);break;
  case 23:
	myimfu_prefs.setIntPref("posttool", 0);posttoolen.setAttribute('checked', false);posttooldis.setAttribute('checked', true);break;
  case 24:
	imfudevbar.setAttribute('mode', "full");imfubar.setAttribute('mode', "full");setfull.setAttribute('checked', true);setficons.setAttribute('checked', false);settext.setAttribute('checked', false);break;
  case 25:
	imfubar.setAttribute('mode', "icons");imfudevbar.setAttribute('mode', "icons");setficons.setAttribute('checked', true);setfull.setAttribute('checked', false);settext.setAttribute('checked', false);break;
  case 26:
	imfubar.setAttribute('mode', "text");imfudevbar.setAttribute('mode', "text");settext.setAttribute('checked', true);setfull.setAttribute('checked', false);setficons.setAttribute('checked', false);break;
  case 27:
  	if(xcleanpref == 0){myimfu_prefs.setIntPref("forextclean", 1);xclean.setAttribute('checked', true);}
  	else{myimfu_prefs.setIntPref("forextclean", 0);xclean.setAttribute('checked', false);}break;
  case 28:
	if(!apitem1.getAttribute('hidden')){apch.setAttribute('checked', false);apitem1.setAttribute('hidden', true);apitem2.setAttribute('hidden', true);apitem3.setAttribute('hidden', true);apitem4.setAttribute('hidden', true);}
	else{apitem1.removeAttribute('hidden');apitem2.removeAttribute('hidden');apitem3.removeAttribute('hidden');apitem4.removeAttribute('hidden');apch.setAttribute('checked', true);}break;
  case 29:
  if(!vipitem1.getAttribute('hidden')){vipch.setAttribute('checked', false);vipitem1.setAttribute('hidden', true);}
  else{	vipitem1.removeAttribute('hidden');vipch.setAttribute('checked', true);}break;
  case 30:
	myimfu_prefs.setIntPref("sitefixes", 1);sitefixen.setAttribute('checked', true);sitefixdis.setAttribute('checked', false);break;
  case 31:
	myimfu_prefs.setIntPref("sitefixes", 0);sitefixen.setAttribute('checked', false);sitefixdis.setAttribute('checked', true);break;}}

// Search
function myimfu_search(event, type){
    var URL = "";
    var isEmpty = false;
    var searchTermsBox = document.getElementById("myimfu_searchterms");
    var searchTerms = myimfu_searchtrim(searchTermsBox.value);
    if(searchTerms.length == 0){isEmpty = true;}
    else{searchTerms = myimfu_searchconv(searchTerms);}
	switch(type){
	case 1:
	if(isEmpty) {URL = "http://www.imvu.com/catalog/";}
	else        {URL = "http://www.imvu.com/shop/web_search.php?keywords=" + searchTerms;}break;
	case 2:
	if(isEmpty) {URL = "http://www.imvu.com/music/";}
	else        {URL = "http://www.imvu.com/music/search.php?term=" + searchTerms + "&field=1";}break;
	case 3:
	if(isEmpty) {URL = "http://www.imvu.com/music/";}
	else        {URL = "http://www.imvu.com/music/search.php?term=" + searchTerms + "&field=2";}break;
	case 4:
	if(isEmpty) {URL = "http://www.imvu.com/music/";}
	else        {URL = "http://www.imvu.com/music/search.php?term=" + searchTerms + "&field=3";}break;
	case 5:
	if(isEmpty) {URL = "http://www.imvu.com/rooms/";}
	else        {URL = "http://www.imvu.com/rooms/index.php?search_terms=" + searchTerms;}break;
	case 6:
	if(isEmpty) {URL = "http://www.imvu.com/catalog/modules.php?op=modload&name=phpbb2&file=index.php";}
	else        {URL = "http://www.google.com/custom?hl=en&client=pub-3440578217129201&cof=FORID%3A1%3BGL%3A1%3BS%3Ahttp%3A%2F%2Fwww.imvu.com%3BL%3Ahttp%3A%2F%2Fwww.imvu.com%2Fcatalog%2Fweb_images%2Ftopnav_logo.gif%3BLH%3A28%3BLW%3A116%3BLBGC%3AFF5A00%3BLC%3A%230066cc%3BVLC%3A%23336633%3BGALT%3A%230066CC%3BGFNT%3A%23666666%3BGIMP%3A%23666666%3BDIV%3A%23999999%3B&domains=http%3A%2F%2Fwww.imvu.com%2Fcatalog%2Fmodules.php%3Fop%3Dmodload&q=" + searchTerms + "&btnG=Search&sitesearch=http%3A%2F%2Fwww.imvu.com%2Fcatalog%2Fmodules.php%3Fop%3Dmodload"; }break;
	case 7:
	if(isEmpty) {URL = "http://www.imvu.com/games/";}
        else        {URL = "http://www.imvu.com/games/?search=" + searchTerms;}break;}
    openUILink(URL, event, false, true);}

function myimfu_searchtrim(string){
    if (!string)
        return "";
        
    string = string.replace(/^\s+/, ''); 
    string = string.replace(/\s+$/, ''); 
    string = string.replace(/\s+/g, ' ');
    return string;
    }

function myimfu_searchconv(terms){
    var termArray = new Array();
    termArray = terms.split(" ");
    var result = "";

    for(var i=0; i<termArray.length; i++)
    {

        if(i > 0)
            result += "+";

        result += encodeURIComponent(termArray[i]);
    }

    return result; 
}

function myimfu_searchkey(event, type){
	switch(type){
    	case 1:
	if(event.keyCode == event.DOM_VK_RETURN)myimfu_search(event, 1);break;
	case 2:
	if(event.keyCode == event.DOM_VK_RETURN)myimfu_search(event, 2);break;
	case 3:
	if(event.keyCode == event.DOM_VK_RETURN)myimfu_search(event, 3);break;
	case 4:
	if(event.keyCode == event.DOM_VK_RETURN)myimfu_search(event, 4);break;
	case 5:
	if(event.keyCode == event.DOM_VK_RETURN)myimfu_search(event, 5);break;
	case 6:
	if(event.keyCode == event.DOM_VK_RETURN)myimfu_search(event, 6);break;
	case 7:
	if(event.keyCode == event.DOM_VK_RETURN)myimfu_search(event, 7);break;}}

function myimfu_searchset(type){
  var	searchstrings = document.getElementById("myimfu-strings"),
	searchTermsBox = document.getElementById("myimfu_searchterms"),
	searchtypeimg = document.getElementById("myimfu_searchdropsel"),
	searchclick = document.getElementById("myimfu_searchclick"),
	stext1 = searchstrings.getString('myimfusearch1'),
	stext2 = searchstrings.getString('myimfusearch2'),
	stext3 = searchstrings.getString('myimfusearch3'),
	stext4 = searchstrings.getString('myimfusearch4'),
	stext5 = searchstrings.getString('myimfusearch5'),
	stext6 = searchstrings.getString('myimfusearch6'),
	stext7 = searchstrings.getString('myimfusearch7');
	switch(type){
	case 1:
	searchTermsBox.setAttribute('placeholder', stext2);
	searchTermsBox.setAttribute('emptytext', stext2);
	searchTermsBox.removeAttribute('onkeypress');
	searchTermsBox.setAttribute('onkeypress', 'myimfu_searchkey(event, 2);');
	searchclick.removeAttribute('onclick');
	searchclick.setAttribute('onclick', 'myimfu_search(event, 2);');
	searchtypeimg.setAttribute('src', 'chrome://myimfu/skin/music.png');
	searchTermsBox.focus();
	break;
	case 2:
	searchTermsBox.setAttribute('placeholder', stext1);
	searchTermsBox.setAttribute('emptytext', stext1);
	searchTermsBox.removeAttribute('onkeypress');
	searchTermsBox.setAttribute('onkeypress', 'myimfu_searchkey(event, 1);');
	searchclick.removeAttribute('onclick');
	searchclick.setAttribute('onclick', 'myimfu_search(event, 1);');
	searchtypeimg.setAttribute('src', 'chrome://myimfu/skin/cart.png');
	searchTermsBox.focus();
        break;
	case 3:
	searchTermsBox.setAttribute('placeholder', stext3);
	searchTermsBox.setAttribute('emptytext', stext3);
	searchTermsBox.removeAttribute('onkeypress');
	searchTermsBox.setAttribute('onkeypress', 'myimfu_searchkey(event, 3);');
	searchclick.removeAttribute('onclick');
	searchclick.setAttribute('onclick', 'myimfu_search(event, 3);');
	searchtypeimg.setAttribute('src', 'chrome://myimfu/skin/music.png');
	searchTermsBox.focus();
	break;
	case 4:
	searchTermsBox.setAttribute('placeholder', stext4);
	searchTermsBox.setAttribute('emptytext', stext4);
	searchTermsBox.removeAttribute('onkeypress');
	searchTermsBox.setAttribute('onkeypress', 'myimfu_searchkey(event, 4);');
	searchclick.removeAttribute('onclick');
	searchclick.setAttribute('onclick', 'myimfu_search(event, 4);');
	searchtypeimg.setAttribute('src', 'chrome://myimfu/skin/music.png');
	searchTermsBox.focus();
	break;
	case 5:
	searchTermsBox.setAttribute('placeholder', stext5);
	searchTermsBox.setAttribute('emptytext', stext5);
	searchTermsBox.removeAttribute('onkeypress');
	searchTermsBox.setAttribute('onkeypress', 'myimfu_searchkey(event, 5);');
	searchclick.removeAttribute('onclick');
	searchclick.setAttribute('onclick', 'myimfu_search(event, 5);');
	searchtypeimg.setAttribute('src', 'chrome://myimfu/skin/door_open.png');
	searchTermsBox.focus();
	break;
	case 6:
	searchTermsBox.setAttribute('placeholder', stext6);
	searchTermsBox.setAttribute('emptytext', stext6);
	searchTermsBox.removeAttribute('onkeypress');
	searchTermsBox.setAttribute('onkeypress', 'myimfu_searchkey(event, 6);');
	searchclick.removeAttribute('onclick');
	searchclick.setAttribute('onclick', 'myimfu_search(event, 6);');
	searchtypeimg.setAttribute('src', 'chrome://myimfu/skin/comments.png');
	searchTermsBox.focus();
	break;
	case 7:
	searchTermsBox.setAttribute('placeholder', stext7);
	searchTermsBox.setAttribute('emptytext', stext7);
	searchTermsBox.removeAttribute('onkeypress');
	searchTermsBox.setAttribute('onkeypress', 'myimfu_searchkey(event, 7);');
	searchclick.removeAttribute('onclick');
	searchclick.setAttribute('onclick', 'myimfu_search(event, 7);');
	searchtypeimg.setAttribute('src', 'chrome://myimfu/skin/controller.png');
	searchTermsBox.focus();
	break;}}

// Strip Titles
document.addEventListener("load", function() { imvustriptitle.init(); }, true);
var imvustriptitle = {
  init: function(){
    var appcontent = document.getElementById("content");
    if(appcontent)
          appcontent.addEventListener("DOMContentLoaded", imvustriptitle.onPageLoad, false);},

  onPageLoad: function(aEvent) {
  if(aEvent.originalTarget.domain == null){return;}else{
   var	titcleanpref = myimfu_prefs.getIntPref("titleclean"),
	seccolpref = myimfu_prefs.getIntPref("seccol"),
	doc = aEvent.originalTarget,
	doc2 = aEvent.originalTarget.location.href;
	striplink = favlink = doc.createElement("link"),
	imvustriprel = favlink.setAttribute('rel', 'shortcut icon');
   if(doc.domain.indexOf("imvu.com") > -1 && titcleanpref == 1 ){
   	gamico = "",
	musico = "%2F9hAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A%2FwD%2FoL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9kJARIdJeeDLRYAAAFuSURBVDjLpZJLS5VRFIaftb79pcfiECSSEElITsSCBomDhv4B6S80ahqN9J846ncI3UAQEmqUgyZNzAsoFHbUc%2FZ6G5zznYt%2BUdk72Xvttfa73nWxhVdf3pnZE2ogiRCEunZIZA18ZoYDxj%2FAL0R7xf63uBjvIVwSkmrlj7zVKQKsqrMiyqGhugf1rz6e5PXTmZEkqSJw6wYvTTco3Zgonc9HZ9xrlpx0xObuT%2FZbmQ8HpyNqUzvkpVs%2F08r9JnM3rzHTLGmHKHtdW9s8ZP7WGMt3r%2FPiLaAAc7zbhwFjDnHnRuLl%2BwNKN55tfANgYXLsUp%2BAbgkCcs8ZggB%2BnGcA2r3Bp%2BHxKfpnkuRRswp14x1%2BUwhzw2bXdz6aFw8rx9J0g%2FHkbO%2B3eDQ1ztZei8XbDU46IhmUbrz5%2Bh0UWFFgs%2Bs7nzB%2F8NvNqeRWZs79uxUFSTm7FX%2FeQIUukfWbeJWPAwKFKXNlpM7x3nP%2BA78AsrC22vixjegAAAAASUVORK5CYII%3D",
	userico = "%2F9hAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A%2FwD%2FoL2nkwAAA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GFV8CFV0EFZ4B7bsAImvolTT77zmQhJ6rxtyA8j4G9IBKuhjQ6QDOM6BygAEjajDGnNncWUMg320GXOcJru4wwTkGVNx8LY3WsJpyMncm3XeL0%2FsZcIXTYwyIanJhhwMou7ZIvjvcPKgmMfLZ3BmzpPfK%2BPHpJWxsbqmxoF2n4NGW5I2mmccN2DM42jGLuq6nKD2WQO3ZGQTCU5LePfwcqblVNRac1imoOLYsCzJjctrjhQ%2F4%2BOkzfgL4%2Bm1bqlG4J430QlbOku61ubYxoCi6Its1b2Slnq3j%2B%2FYPnIjOSnN180OpyUeLSL%2FIOABOz49o5YW8lU9jFlTSjdR8Fl84ucaelOZDDUmpk0%2BWfwO8LQxo1il4nFX5rma7rNR8RgGRCQWE4g7gDQPWFGDMe5sURPl2RrZqPg0r0JRAsHUCuw%2FEELQfYJfVyTWJw%2FUjONI4imBkXM2eBn0G07KyDLMYl9pU3lZn5IiT3Khmz0n%2BHWaAJ7QuDeY9LrX8YTzlNufV6z3l1b2Tw7%2FkMobUmJMA9hx%2FLw07SUxOYi71LwDRwf%2FRL3EN0OI%2B5a2bAAAAAElFTkSuQmCC",
	eduico = "",
	prico = "";
     	if(doc2.search("avatars.imvu.com") > -1 || doc2.search("imvu.com/catalog/web_mypage.php") > -1){
		doc.title = doc.title.replace('IMVU: My avatar page: Guest_', '').replace('IMVU: My avatar page: ', '');}
	else if(doc2.search("name=phpbb2") > -1){
 		doc.title = doc.title.replace('IMVU - View topic - ', '').replace('&amp;', '&').replace('IMVU - View Forum - ', '').replace('IMVU - Index', 'Forum Overview').replace(/&quot;/g, '"').replace('- IMVU Related', '').replace('- NEW', '').replace('IMVU - ', '');}
 	else if(doc2.search("imvu.com/shop") > -1 || doc2.search("imvu.com/catalog/products_new.php") > -1 || doc2.search("imvu.com/catalog/web_prod_tag_search_result.php") > -1){
 		doc.title = doc.title.replace('IMVU Catalog: ', '').replace('IMVU Product: ', '').replace(': Shop - IMVU', '');}
 	else if(doc2.search("imvu.com/groups") > -1){
 		if(doc2.search("imvu.com/groups/group/") > -1){
		var grouptitle = doc.getElementById("breadcrumb").childNodes[5].childNodes[0].textContent;
		doc.title = grouptitle;}
		else{doc.title = doc.title.replace('IMVU: Group: ', '').replace(' - IMVU Groups', '').replace('IMVU Groups: Meet new people with the same interests', 'Groups');}}
	else if(doc2.search("imvu.com/music/album.php") > -1){
		var albumpagetitle = doc.getElementById("breadcrumb").childNodes[9].childNodes[0].wholeText;
	    	doc.title = albumpagetitle;}	
	else if(doc2.search("imvu.com/music/genre.php") > -1){
	    	var genrepagetitle = doc.getElementById("breadcrumb").childNodes[5].childNodes[0].wholeText;
		doc.title = genrepagetitle;} 
	else if(doc2.search("imvu.com/music/artist.php") > -1){
	    	var musicpagetitle = doc.getElementById("breadcrumb").childNodes[7].childNodes[0].textContent;
		doc.title = musicpagetitle;} 
 	else if(doc2.search("imvu.com/music/") > -1){
 		doc.title = doc.title.replace('IMVU Music', 'Music Store');}
	else if(doc2.search("imvu.com/catalog/newsletter/video.php") > -1){
		doc.title = 'Videos';}
	else if(doc2.search("imvu.com/neighborhoods/") > -1){
 		doc.title = doc.title.replace('3D Chat', 'Public').replace('Virtual ', '').replace(': IMVU', '');}
 	else if(doc2 == "imvu.com/catalog/invite/inviter.php"){
 		doc.title = 'Invite a friend';}
	else if(doc2 == "imvu.com/catalog/gifts.php?nav_section=shopping&nav_subsection=gifts"){
 		doc.title = 'Gifts';}
  	else if(doc2 == "imvu.com/catalog/shopping_cart.php"){
  		doc.title = 'Shopping Cart';}
 	else if(doc2 == "imvu.com/catalog/web_index.php/music"){
 		doc.title = 'Manage Mixes';}
	else if(doc2 == "imvu.com/catalog/web_index.php/updates"){
 		doc.title = 'Updates';}
	else if(doc2 == "imvu.com/catalog/web_info.php?topic=terms_of_service"){
 		doc.title = 'Terms of Service';}
	else if(doc2 == "imvu.com/catalog/web_info.php?topic=mature_content_policy"){
 		doc.title = 'Virtual Goods Policy';}
	else if(doc2 == "imvu.com/catalog/web_info.php?topic=privacy"){
 		doc.title = 'Privacy Policy';}
	else if(doc2.search("imvu.com/catalog/web_credits_balance_log.php") > -1){
 		doc.title = 'Credit Balance Log';}
 	else if(doc2.search("imvu.com/creators/") > -1){
		doc.title = doc.title.replace(' - IMVU Creator', '');}
	else if(doc2.search("imvu.com/games/") > -1){
		if(doc2.search("imvu.com/games/play/") > -1){
		var gstr = doc2.substr(1).split("/")[6];
		var gresult = gstr.charAt(0).toUpperCase() + gstr.slice(1);
		doc.title = gresult;}
		else if(doc2.search("http://www.imvu.com/games/category/") > -1){
		var gcatname = doc.getElementById("category-title").childNodes[0].textContent;
		doc.title = gcatname;}}
	else{doc.title = doc.title.replace('IMVU: ', '').replace(' : IMVU', '').replace(': IMVU', '').replace(': 3D Chat Rooms', '');}}
   if(doc.domain.indexOf("imvu.com") > -1 && seccolpref == 1 ){
     	if(doc2.search("http://avatars.imvu.com") > -1 || doc2.search("http://www.imvu.com/catalog/web_mypage.php") > -1){
		striplink;imvustriprel;favlink.setAttribute("href", userico);doc.getElementsByTagName("head")[0].appendChild(favlink);}
	else if(doc2.search("name=phpbb2") > -1){
		striplink;imvustriprel;favlink.setAttribute('href', forico);doc.getElementsByTagName("head")[0].appendChild(favlink);}
	else if(doc2.search("imvu.com/shop") > -1 || doc2.search("imvu.com/catalog/products_new.php") > -1 || doc2.search("imvu.com/catalog/web_prod_tag_search_result.php") > -1){
		striplink;imvustriprel;favlink.setAttribute("href", catico);doc.getElementsByTagName("head")[0].appendChild(favlink);}
	else if(doc2.search("imvu.com/groups") > -1 || doc2 == "http://www.imvu.com/groups/"){
		striplink;imvustriprel;favlink.setAttribute('href', groico);doc.getElementsByTagName("head")[0].appendChild(favlink);}
	else if(doc2.search("imvu.com/music/") > -1){
		striplink;imvustriprel;favlink.setAttribute("href", musico);doc.getElementsByTagName("head")[0].appendChild(favlink);}
	else if(doc2.search("imvu.com/games/") > -1){
		striplink;imvustriprel;favlink.setAttribute("href", gamico);doc.getElementsByTagName("head")[0].appendChild(favlink);}
	else if(doc2.search("imvu.com/neighborhoods/") > -1){
		striplink;imvustriprel;favlink.setAttribute('href', neigico);doc.getElementsByTagName("head")[0].appendChild(favlink);}
	else if(doc2.search("imvu.com/creators/") > -1){
		striplink;imvustriprel;favlink.setAttribute('href', eduico);doc.getElementsByTagName("head")[0].appendChild(favlink);}
	else if(doc2.search("imvu.com/rooms/") > -1){
		striplink;imvustriprel;favlink.setAttribute('href', prico);doc.getElementsByTagName("head")[0].appendChild(favlink);}
	else {striplink;imvustriprel;favlink.setAttribute('href', othico);doc.getElementsByTagName("head")[0].appendChild(favlink);}}}}}
document.removeEventListener("load", function() { imvustriptitle.init(); }, false);